#include "camera.h"

void Camera::draw() {
	glRotatef(angle, 0.0, 0.0, 1.0);
	glOrtho(pos_.x - hWidth, pos_.x + hWidth, pos_.y - hHeight, pos_.y + hHeight, -1.0, 1.0);
}

void Camera::update(float step) {
    if(forwards) {
        float move = speed * hHeight;
		pos_.y += move;
	}
	if(back) {
		float move = speed * hHeight;
		pos_.y -= move;
	}
	if(right) {
		float move = speed * hHeight;
		pos_.x += move;
	}
	if(left) {
		float move = speed * hHeight;
		pos_.x -= move;
	}

	if(rotateRight) {
		angle -= rotate;
	}
	if(rotateLeft) {
		angle += rotate;
	}

	if(in) {
	    float zoom = zoomSpeed * hHeight;
		hWidth -= (zoom * aRatio);
		hHeight -= zoom;		
	}
	if(out) {
		float zoom = zoomSpeed * hHeight;
		hWidth += (zoom * aRatio);
		hHeight += zoom;
	}
}

void Camera::moveForwards() {
	forwards = true;
}

void Camera::stopMoveForwards() {
	forwards = false;
}

void Camera::moveRight() {
	right = true;
}

void Camera::stopMoveRight() {
	right = false;
}

void Camera::moveLeft() {
	left = true;
}

void Camera::stopMoveLeft() {
	left = false;
}

void Camera::moveBack() {
	back = true;
}

void Camera::stopMoveBack() {
	back = false;
}

void Camera::spinRight() {
	rotateRight = true;
}

void Camera::stopSpinRight() {
	rotateRight = false;
}

void Camera::spinLeft() {
	rotateLeft = true;
}

void Camera::stopSpinLeft() {
	rotateLeft = false;
}

void Camera::zoomIn() {
	in = true;
}

void Camera::stopZoomIn() {
	in = false;
}

void Camera::zoomOut() {
	out = true;
}

void Camera::stopZoomOut() {
	out = false;
}
